package com.xuliugen.lsm.util;

import java.util.Map;
import java.util.concurrent.Callable;

import com.xuliugen.lsm.core.SSTable;

public class Task<K extends Comparable<K>,V> implements Callable<SSTable<K,V>> {

	private SSTable<K,V> ss ;

	private SSTable<K,V> st ;

	private Vector<K,V> ssTable;

	private int left ;

	private final Map<? extends Comparable<?>,Integer> deleted;

	public Task(Vector<K, V> ssTable, int left, int right, Map<K, Integer> deleted) {
		this.deleted = deleted;
		this.ssTable = ssTable;
		this.left = left;
		ss = this.ssTable.get(left);
		st = this.ssTable.get(right);
	}

	@Override
	public SSTable<K,V> call() {
		this.ssTable.put(TreeUtil.memgerTwoBtree(ss,st,deleted), left);
		return this.ssTable.get(left);
	}
	
}
